//
//  HeaderView.swift
//  GOFM
//
//  Created by siri on 2024/10/21.
//  Copyright © 2024 Glad. All rights reserved.
//

import SwiftUI


struct HeadView: View {
       let currentYear:String = String(Date.getCurrentYearNum())// 当前年份
       let currentDay:String = String(Date().getCurrentDay()  )  // 当前日期
       var title:String // 头部标题
    
       @State var currentMonth:String = String(Date.getCurrentMonthNum())// 当前月
       @Binding var showingPopup:Bool  // 显示日历弹窗
       
        
       let monthArray = ["1月", "2月","3月", "4月","5月", "6月","7月", "8月","9月", "10月","11月", "12月"]
       
       var body: some View {
           VStack{
               Text(title).bold().foregroundColor(Color.g_color_font_white)
               HStack {
                   Text(currentDay)
                       .font(.largeTitle)
                       .foregroundColor(Color.g_color_font_white)
                   VStack(alignment: .leading,spacing:0) {
                       Text(currentYear)
                           .foregroundColor(Color.g_color_font_white)
                       ZStack(alignment: .leading){
                           Button(action: {
                               showingPopup = !showingPopup
                           }){
                               Text("").frame(width: 30,height: 10).padding(.leading,30).background(
                                   Path { path in
                                               path.move(to: CGPoint(x: 44, y:14))
                                               path.addLine(to: CGPoint(x: 50, y: 14))
                                       path.addLine(to: CGPoint(x: 47, y: 19))
                                              path.addLine(to: CGPoint(x: 44, y:14))
                                           }
                                    .fill(Color.g_color_font_white)
                               )
                           }.offset(x: -5,y: -10)
                              
                         
                           Text("\(currentMonth)月")
                               .foregroundColor(Color.g_color_font_white).frame(alignment: .top) 
                       }
                   }
               }.offset(x: 140,y:-10)

           }.frame(minWidth: 0,   maxWidth: .infinity,minHeight: 55,maxHeight: 55).background(Color.g_color_theme)
       }
    
}



struct HeaderView_Previews: PreviewProvider {
    static var previews: some View {
        Text("nihao")
//        HeadView(title: "我的会议")
    }
}
